<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/css/bootstrap-switch.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-parameter-add">
			<input id="apiProjectnameId" name="apiProjectnameId" type="hidden" th:value="${project.apiProjectnameId}"   />
			<input id="required" name="required" type="hidden" th:value="0" >
			<div class="form-group">
				<label class="col-sm-3 control-label">所属项目：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" id="treeName" readonly="true" th:value="${project.description}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">参数名称：</label>
				<div class="col-sm-8">
					<input id="parameter" name="parameter" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">参数描述：</label>
				<div class="col-sm-8">
					<input id="description" name="description" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">默认值：</label>
				<div class="col-sm-8">
					<input id="defaultValue" name="defaultValue" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">传参方式：</label>
				<div class="col-sm-8">
					<!--<input id="transmissionMode" name="transmissionMode" class="form-control" type="text">-->
					<select id="transmissionMode" name="transmissionMode" class="form-control m-b" th:with="type=${@dict.getType('param_transmission_mode')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">参考值：</label>
				<div class="col-sm-8">
					<input id="referenceValue" name="referenceValue" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">值类型：</label>
				<div class="col-sm-8">
					<!--<input id="method"  name="method" class="form-control" type="text">-->
					<select id="valueType" name="valueType" class="form-control m-b" th:with="type=${@dict.getType('api_value_type')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<!--<div class="form-group">-->
				<!--<label class="col-sm-3 control-label">是否必填：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="required" name="required" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">是否必填：</label>
				<div class="col-sm-8">
					<!--<div class="onoffswitch">-->
						<!--<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="required" name="required">-->
						<!--<label class="onoffswitch-label" for="required">-->
							<!--<span class="onoffswitch-inner"></span>-->
							<!--<span class="onoffswitch-switch"></span>-->
						<!--</label>-->
					<!--</div>-->
						<input type="checkbox" id="checked_required" name="checked_required" />
				</div>
			</div>
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">创建者：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="createBy" name="createBy" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">创建时间：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="createTime" name="createTime" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">更新者：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="updateBy" name="updateBy" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">更新时间：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="updateTime" name="updateTime" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/js/bootstrap-switch.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "module/parameter";
		$("#form-parameter-add").validate({
			rules:{
				parameter:{
					required:true,
				},
                description:{
                    required:true,
                },
			},
			submitHandler: function(form) {
				$.operate.save(prefix + "/add", $('#form-parameter-add').serialize());
			}
		});
        $("#checked_required").bootstrapSwitch({
            onText:"√",
            offText:"×",
            onColor:"success",
            offColor:"default",
            size:"small",
            onSwitchChange: function(event,state) {
                console.log("state="+state);
                console.log(event);
                event
                if (state == true) {
                    $("#required").val('1');
                } else {
                    $("#required").val('0');
                }
            }
        });
        // $("#checked_required").attr("checked", true);
	</script>
</body>
</html>
